package au.com.iglootech.TaxTimeToolTip.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateUtils {
	public static String formateDate(Date date)
	{
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
		return df.format(date); 
	}
	
	/**
	 * The start date of system is 2012.1.16
	 * @return
	 */
	public static Date systemStartDate()
	{
		Calendar calendar = Calendar.getInstance();
		calendar.set(Calendar.YEAR, 2012);
		calendar.set(Calendar.MONTH, 1);
		calendar.set(Calendar.DAY_OF_MONTH, 16);
		return calendar.getTime();
	}
	
	/**
	 * The end date of system is 2022.1.16
	 * @return
	 */
	public static Date systemEndDate()
	{
		Calendar calendar = Calendar.getInstance();
		calendar.set(Calendar.YEAR, 2022);
		calendar.set(Calendar.MONTH, 1);
		calendar.set(Calendar.DAY_OF_MONTH, 16);
		return calendar.getTime();
	}
	
	/**
	 * This function only can been used in the server side.
	 * @param date
	 * @return
	 */
	public static Date getBeginOfDate(Date date)
	{
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.set(Calendar.HOUR_OF_DAY, 0);
		calendar.set(Calendar.MINUTE, 0);
		calendar.set(Calendar.SECOND, 0);
		return calendar.getTime();
	}
	
	/**
	 * This function only can been used in the server side.
	 * @param date
	 * @return
	 */
	public static Date getEndOfDate(Date date)
	{
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.set(Calendar.HOUR_OF_DAY, 23);
		calendar.set(Calendar.MINUTE, 59);
		calendar.set(Calendar.SECOND, 59);
		return calendar.getTime();
	}
}
